package ils.domain.issue.model;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class ShelfRepositoryImpl implements ShelfRepository
{
    private SessionFactory sessionFactory;
    @Override
    public Shelf getShelf(int shelfId)
    {
       Session session = sessionFactory.getCurrentSession();
       return (Shelf)session.get(Shelf.class, shelfId);
    }
    public void setSessionFactory(SessionFactory sessionFactory)
    {
        this.sessionFactory = sessionFactory;
    }

    @Override
    public Shelf createShelf(Shelf shelf) {
        Session session = sessionFactory.getCurrentSession();
        session.save(shelf);
        return shelf;
    }
}
